{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "903df834-8323-4fec-bda7-b69d98cbec30",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/linked-list-cycle-ii\n",
    "\n",
    "\n",
    "Runtime: 816 ms, faster than 5.01% of Python3 online submissions for Linked List Cycle II.\n",
    "Memory Usage: 17.3 MB, less than 22.85% of Python3 online submissions for Linked List Cycle II.\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def detectCycle(self, head: ListNode) -> ListNode:\n",
    "        #6:27\n",
    "        nodes = []\n",
    "        ids = []\n",
    "        \n",
    "        node = head\n",
    "        index = 0\n",
    "        while node != None:\n",
    "            ok = False\n",
    "            id_ = id(node)\n",
    "            if (id_ in ids):\n",
    "                ok = True\n",
    "            ids.append(id_)\n",
    "            nodes.append(node)\n",
    "            if (ok == True):\n",
    "                return nodes[index]\n",
    "            node = node.next\n",
    "            index += 1\n",
    "        return None\n",
    "        #6:33\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a01f8a57-6d60-4356-a3b9-7babfb945cba",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
